package com.spsy.pay.controller.mq;

import com.spsy.common.core.domain.R;
import com.spsy.common.core.utils.uuid.UUID;
import com.spsy.pay.constant.RabbitMqConstantCompany;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/mq")
public class RabbitMqCompanyController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/send")
    public R send(){
        log.info("发送的消息，send-------------");

        CorrelationData data = new CorrelationData(UUID.randomUUID().toString());

//        rabbitTemplate.convertAndSend(RabbitMqConstantCompany.MQ_EXCHANGE,RabbitMqConstantCompany.MQ_ROUTTING,"2302A-孙梦初测试消息",data);
        rabbitTemplate.convertAndSend("fdsfsfsedfrww",RabbitMqConstantCompany.MQ_ROUTTING,"2302A-孙梦初测试消息",data);
//        rabbitTemplate.convertAndSend(RabbitMqConstantCompany.MQ_EXCHANGE,"dgdfgsdg3243dfs","2302A-孙梦初测试消息",data);

        return R.ok();
    }

}
